package top.linuyx.mapper;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import top.linuyx.pojo.entity.AccountEntity;
import top.linuyx.pojo.param.AccountRegisterParam;

/**
 * @Author Linuyx
 * @Description AccountMapper
 * @Date Created in 2021-04-09 9:23
 */

@Repository
public interface AccountMapper {

    /**
     * 注册
     *
     * @param registerParam 注册请求体
     */
    void register(AccountRegisterParam registerParam);

    /**
     * 根据用户名查询账户
     *
     * @param username 用户名
     * @return AccountEntity
     */
    @Select("select username,password,salt from account where username=#{username} and is_deleted=0")
    AccountEntity getAccountByUsername(@Param("username") String username);

    /**
     * 根据用户名和角色查询账户
     *
     * @param username 用户名
     * @param role 角色
     * @return AccountEntity
     */
    AccountEntity getAccountByUsernameAndRole(@Param("username") String username, @Param("role") String role);

}
